//实现接口角色
interface implementor {
    doAnything(): void
    doSomething(): void
}

//具体实现角色1
class ConcreateImplementor1 implements implementor {
    doAnything(): void {
        console.log("doAnything :>> ");
    }
    doSomething(): void {
        console.log("doSomething :>> ");
    }

}

//具体实现角色2
class ConcreateImplementor2 implements implementor {
    doAnything(): void {

    }
    doSomething(): void {

    }
}

//抽象类
abstract class Abstarction {
    private imp: implementor
    constructor(imp: implementor) {
        this.imp = imp
    }
    //自身行为和属性
    public request(): void {
        this.imp.doSomething()
    }
}

//具体抽象化角色
class RefinedAbstraction extends Abstarction {
    constructor(imp: implementor) {
        super(imp)
    }

    public request(): void {
        //业务逻辑
        super.request()
    }
}

//调用
const imp: implementor = new ConcreateImplementor1()
const abs: Abstarction = new RefinedAbstraction(imp)
abs.request()
